Skip to content

fix: non editable paragraphs insertion - #131

Merged
IvanIhnatsiuk merged 1 commit into
developmentfrom
fix/non-editable-paragraphs-insertion
Jul 21, 2026
Merged

fix: non editable paragraphs insertion#131
IvanIhnatsiuk merged 1 commit into
developmentfrom
fix/non-editable-paragraphs-insertion

Conversation

@IvanIhnatsiuk

Copy link
Copy Markdown
Collaborator

Summary

This pull request improves how newlines are inserted before non-editable paragraph spans in the NonEditableParagraphFilter class. The main change is to ensure that a newline is only prepended if the inserted text does not already start with one, preventing duplicate newlines.

Enhancements to newline handling:

  • Added the prependNewlineIfMissing method to check if the inserted text already starts with a newline and only prepend one if necessary.
  • Updated logic in two places to use prependNewlineIfMissing instead of unconditionally prepending a newline, improving the user experience and preventing unwanted extra newlines.

Imports:

  • Added import for SpannableStringBuilder to support the new method.

Test Plan

  1. Apply any paragraph styles
  2. Toggle divider style
  3. Toggle divider style again

Screenshots / Videos

Screen.Recording.2026-07-21.at.01.54.13.mov

Compatibility

OS Implemented
iOS
Android

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adjusts Android’s NonEditableParagraphFilter to avoid inserting duplicate newlines when text is inserted at the boundary of a non-editable paragraph span.

Changes:

  • Added prependNewlineIfMissing(...) to prepend a newline only when the inserted text doesn’t already start with one.
  • Updated two insertion paths to use prependNewlineIfMissing(...) instead of unconditionally prefixing \n.
  • Added SpannableStringBuilder usage to build the resulting inserted text while preserving span behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 36 to 38
if (spanEnd == dstart) {
return Strings.NEWLINE_STRING + source
return prependNewlineIfMissing(source, start, end)
}
@IvanIhnatsiuk
IvanIhnatsiuk merged commit a0915e7 into development Jul 21, 2026
1 check passed
@IvanIhnatsiuk
IvanIhnatsiuk deleted the fix/non-editable-paragraphs-insertion branch July 21, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants